<?php
/**
 * Created by PhpStorm.
 * Author: 黑瞎子
 * Date: 2018/4/7
 * Time: 21:08
 */

namespace app\api\behavior;


class CORS
{
    public function appInit(&$params){
        // 指定允许其他域名访问
        header('Access-Control-Allow-Origin:*');
        // 响应类型
        header('Access-Control-Allow-Methods:POST,GET,DELETE');
        // 响应头设置 - 允许headers中携带的键值对
        header('Access-Control-Allow-Headers:x-requested-with,content-type,Accept,token,Origin');
        // 上传
        header('Content-Type:multipart/form-data');
        if (request()->isOptions()){
            exit();
        }
    }
}